package com.swf.seed.txt.file;

import java.io.IOException;
import java.util.LinkedList;
import java.util.List;


import com.swf.common.utils.FwsIOUtils;

public class ThreadLocalThread implements Runnable{
	private List<String> list = new LinkedList<String>();
	public ThreadLocalThread(List<String> list) {
	  this.list  = list;
	}
	private static long begin;
	private static long end;
	
	public static int count =0;
		@Override
		public void run() {
			FwsIOUtils io = FwsIOUtils.getInstance().setAppend(true).setCharst("GBK").setOutPath("d:/a/thread/"+Thread.currentThread().getName()+(count++)+".txt");
			for (String s:list){
				if ("0".equals(s)){
					begin = System.currentTimeMillis();
				}else if ("99999".equals(s)){
					end = System.currentTimeMillis();
					System.out.println(end-begin);
				}
				io.setContent(s);
				try {
					io.writeByline();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		public List<String> getList() {
			return list;
		}
		public void setList(List<String> list) {
			this.list = list;
		}
		
		public static void main(String[] args) {
			LinkedList<String> l = new LinkedList<String>();
			for (int i=0;i<10000;i++){
				l.add(i+"");
			}
			new ThreadLocalThread(l).run();
		}
}
